package BiTree;

/**
 * @program: java_concurrent
 * @description: 翻转二叉树，左变右，右变左
 * @author: lxf
 * @create: 2024-06-25 14:59
 **/
public class InvertTree {

    public static void main(String[] args) {
        TreeNode node7 = new TreeNode(6, null, null);
        TreeNode node5 = new TreeNode(4, null, null);
        TreeNode node4 = new TreeNode(3, null, null);
        TreeNode node3 = new TreeNode(3, null, null);
        TreeNode node2 = new TreeNode(1, null, null);
        TreeNode node1 = new TreeNode(2, node2, node3);
        invertTree(node1);
        System.out.println(1);
    }

    public static TreeNode invertTree(TreeNode root) {
        if (root == null) return null;
        TreeNode tmpL = invertTree(root.left);
        TreeNode tmpR = invertTree(root.right);
        root.left = tmpR;
        root.right = tmpL;
        return root;
    }

}
